报错:Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and |
您所在的位置:网站首页 › includ ing › 报错:Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and |
文章首发观看更佳 报错:Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selector 官网给出的解释是:https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/wxml-wxss.html 组件样式组件对应 wxss 文件的样式,只对组件wxml内的节点生效。编写组件样式时,需要注意以下几点: 组件和引用组件的页面不能使用id选择器(#a)、属性选择器([a])和标签名选择器,请改用class选择器。组件和引用组件的页面中使用后代选择器(.a .b)在一些极端情况下会有非预期的表现,如遇,请避免使用。子元素选择器(.a>.b)只能用于 view 组件与其子节点之间,用于其他组件可能导致非预期的情况。继承样式,如 font 、 color ,会从组件外继承到组件内。除继承样式外, app.wxss 中的样式、组件所在页面的的样式对自定义组件无效(除非更改组件样式隔离选项)。 #a { } /* 在组件中不能使用 */ [a] { } /* 在组件中不能使用 */ button { } /* 在组件中不能使用 */ .a > .b { } /* 除非 .a 是 view 组件节点,否则不一定会生效 */ |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |